package leetcode.code2529;

public class Solution {
    public int maximumCount(int[] nums) {
    	return Math.max(bisect_left(nums, 0), nums.length - bisect_right(nums, 0)); 
    }
    
    int bisect_left(int[] a, int x) {
		int lo = 0, hi = a.length;
		while (lo < hi) {
			int mid = ((hi - lo) >> 1) + lo;
			if (a[mid] < x) {
				lo = mid + 1;
			} else {
				hi = mid;
			}
		}
		return lo;
	}

	int bisect_right(int[] a, int x) {
		int lo = 0, hi = a.length;
		while (lo < hi) {
			int mid = ((hi - lo) >> 1) + lo;
			if (a[mid] <= x) {
				lo = mid + 1;
			} else {
				hi = mid;
			}
		}
		return hi;
	}
}
